spv: minimal OpSpecConstantOp and OpConstantFunctionPointerINTEL support.
#22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(each commit should be reviewed separately)
Temporarily based on:
memmodule (for "memory" ops/passes/etc.), out ofqptr. #25The
OpSpecConstantOpsupport is pretty simple/limited (i.e. interpretingLiteralSpecConstantOpIntegeroperands as a SPIR-V opcode followed by all the operands an instruction with that opcode would need).While
OpSpecConstantOpcan be used to do simple arithmetic on specialization constants (as its name may imply), it's also SPIR-V's equivalent of a LLVMConstantExpr, so it includes the kind of pointer operations (e.g.OpAccessChainandOpBitcast) necessary to produce non-trivial pointer values for e.g. initializing globals.Actually doing anything with such constants isn't implemented, but being able to load a SPIR-V module containing them is a prerequisite for generating them within Rust-GPU for better diagnostics and debuggability etc.
OTOH,
OpConstantFunctionPointerINTELsupport is far more involved, due to two related issues:Funcfrom aConst(ConstKind::PtrToFunchad to be added)(done by allocating a
Funcwith a dummy declaration, later replaced by the actual function)SPIR-T -> SPIR-V is much easier, just because all the IDs in the module get allocated early anyway.
On top of the constants themselves, function pointer types (i.e. using
CodeSectionINTELas the storage class) are intentionally ignored byqptr, as all plans for some kind of function pointer emulation (likely as part of recursion emulation) don't really fit theqptrframework and would work more like a disjoint address space (a la Harvard architectures).But just like with
OpSpecConstantOp, the main usecase right now is limited to diagnostics/debuggability.